
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>写入数据 · InfluxDB中文文档</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="jasper">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-comment/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="querying_data.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://legacy.gitbook.com/book/jasper-zhang1/influxdb" target="_blank" class="custom-link">InfluxDB中文文档</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Introduction/">
            
                <a href="../Introduction/">
            
                    
                    介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Introduction/installation.html">
            
                <a href="../Introduction/installation.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Introduction/getting_start.html">
            
                <a href="../Introduction/getting_start.html">
            
                    
                    入门指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    使用指南
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="writing_data.html">
            
                <a href="writing_data.html">
            
                    
                    写入数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="querying_data.html">
            
                <a href="querying_data.html">
            
                    
                    查询数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="downsampling_and_retention.html">
            
                <a href="downsampling_and_retention.html">
            
                    
                    采样和数据保留
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="hardware_sizing.html">
            
                <a href="hardware_sizing.html">
            
                    
                    硬件指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="https_setup.html">
            
                <a href="https_setup.html">
            
                    
                    HTTPS设置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Concepts/">
            
                <a href="../Concepts/">
            
                    
                    概念介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Concepts/key_concepts.html">
            
                <a href="../Concepts/key_concepts.html">
            
                    
                    关键概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Concepts/glossary.html">
            
                <a href="../Concepts/glossary.html">
            
                    
                    专业术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Concepts/crosswalk.html">
            
                <a href="../Concepts/crosswalk.html">
            
                    
                    与SQL比较
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Concepts/insights_tradeoffs.html">
            
                <a href="../Concepts/insights_tradeoffs.html">
            
                    
                    InfluxDB的设计见解和权衡
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../Concepts/schema_and_data_layout.html">
            
                <a href="../Concepts/schema_and_data_layout.html">
            
                    
                    schema设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../Concepts/storage_engine.html">
            
                <a href="../Concepts/storage_engine.html">
            
                    
                    存储引擎
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Write_protocols/">
            
                <a href="../Write_protocols/">
            
                    
                    写入协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Write_protocols/line_protocol.html">
            
                <a href="../Write_protocols/line_protocol.html">
            
                    
                    行协议
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../Query_language/">
            
                <a href="../Query_language/">
            
                    
                    查询语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../Query_language/data_exploration.html">
            
                <a href="../Query_language/data_exploration.html">
            
                    
                    数据查询语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../Query_language/schema_exploration.html">
            
                <a href="../Query_language/schema_exploration.html">
            
                    
                    schema查询语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../Query_language/database_management.html">
            
                <a href="../Query_language/database_management.html">
            
                    
                    数据库管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../Query_language/continuous_queries.html">
            
                <a href="../Query_language/continuous_queries.html">
            
                    
                    连续查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../Query_language/functions.html">
            
                <a href="../Query_language/functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../Query_language/math_operators.html">
            
                <a href="../Query_language/math_operators.html">
            
                    
                    数学运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../Query_language/authentication_and_authorization.html">
            
                <a href="../Query_language/authentication_and_authorization.html">
            
                    
                    认证和授权
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Troubleshooting/">
            
                <a href="../Troubleshooting/">
            
                    
                    故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../Troubleshooting/faq.html">
            
                <a href="../Troubleshooting/faq.html">
            
                    
                    FAQ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../Troubleshooting/system_monitor.html">
            
                <a href="../Troubleshooting/system_monitor.html">
            
                    
                    系统监控
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../Troubleshooting/query_management.html">
            
                <a href="../Troubleshooting/query_management.html">
            
                    
                    查询管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../Troubleshooting/error_messages.html">
            
                <a href="../Troubleshooting/error_messages.html">
            
                    
                    错误信息
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >写入数据</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x5199;&#x5165;&#x6570;&#x636E;">&#x5199;&#x5165;&#x6570;&#x636E;</h1>
<p>&#x6709;&#x5F88;&#x591A;&#x53EF;&#x4EE5;&#x5411;InfluxDB&#x5199;&#x6570;&#x636E;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x5305;&#x62EC;&#x547D;&#x4EE4;&#x884C;&#x3001;&#x5BA2;&#x6237;&#x7AEF;&#x8FD8;&#x6709;&#x4E00;&#x4E9B;&#x50CF;<code>Graphite</code>&#x6709;&#x4E00;&#x6837;&#x6570;&#x636E;&#x683C;&#x5F0F;&#x7684;&#x63D2;&#x4EF6;&#x3002;&#x8FD9;&#x7BC7;&#x6587;&#x7AE0;&#x5C06;&#x4F1A;&#x5C55;&#x793A;&#x600E;&#x6837;&#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;&#x5167;&#x5EFA;&#x7684;HTTP&#x63A5;&#x53E3;&#x5199;&#x5165;&#x6570;&#x636E;&#x3002;</p>
<h2 id="&#x4F7F;&#x7528;http&#x63A5;&#x53E3;&#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93;">&#x4F7F;&#x7528;HTTP&#x63A5;&#x53E3;&#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93;</h2>
<p>&#x4F7F;&#x7528;<code>POST</code>&#x65B9;&#x5F0F;&#x53D1;&#x9001;&#x5230;URL&#x7684;<code>/query</code>&#x8DEF;&#x5F84;&#xFF0C;&#x53C2;&#x6570;<code>q</code>&#x4E3A;<code>CREATE DATABASE &lt;new_database_name&gt;</code>&#xFF0C;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x53D1;&#x9001;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x5230;&#x672C;&#x5730;&#x8FD0;&#x884C;&#x7684;InfluxDB&#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93;<code>mydb</code>:</p>
<pre><code>curl -i -XPOST http://localhost:8086/query --data-urlencode &quot;q=CREATE DATABASE mydb&quot;
</code></pre><h2 id="&#x4F7F;&#x7528;http&#x63A5;&#x53E3;&#x5199;&#x6570;&#x636E;">&#x4F7F;&#x7528;HTTP&#x63A5;&#x53E3;&#x5199;&#x6570;&#x636E;</h2>
<p>&#x901A;&#x8FC7;HTTP&#x63A5;&#x53E3;<code>POST</code>&#x6570;&#x636E;&#x5230;<code>/write</code>&#x8DEF;&#x5F84;&#x662F;&#x6211;&#x4EEC;&#x5F80;InfluxDB&#x5199;&#x6570;&#x636E;&#x7684;&#x4E3B;&#x8981;&#x65B9;&#x5F0F;&#x3002;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x5199;&#x4E86;&#x4E00;&#x6761;&#x6570;&#x636E;&#x5230;<code>mydb</code>&#x6570;&#x636E;&#x5E93;&#x3002;&#x8FD9;&#x6761;&#x6570;&#x636E;&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;&#x662F;measurement&#x4E3A;<code>cpu_load_short</code>&#xFF0C;tag&#x7684;key&#x4E3A;host&#x548C;region&#xFF0C;&#x5BF9;&#x5E94;tag&#x7684;value&#x662F;<code>server01</code>&#x548C;<code>us-west</code>&#xFF0C;field&#x7684;key&#x662F;<code>value</code>&#xFF0C;&#x5BF9;&#x5E94;&#x7684;&#x6570;&#x503C;&#x4E3A;<code>0.64</code>&#xFF0C;&#x800C;&#x65F6;&#x95F4;&#x6233;&#x662F;<code>1434055562000000000</code>&#x3002;</p>
<pre><code>curl -i -XPOST &apos;http://localhost:8086/write?db=mydb&apos; --data-binary &apos;cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000&apos;
</code></pre><p>&#x5F53;&#x5199;&#x5165;&#x8FD9;&#x6761;&#x6570;&#x636E;&#x70B9;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F60;&#x5FC5;&#x987B;&#x660E;&#x786E;&#x5B58;&#x5728;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x5BF9;&#x5E94;&#x540D;&#x5B57;&#x662F;<code>db</code>&#x53C2;&#x6570;&#x7684;&#x503C;&#x3002;&#x5982;&#x679C;&#x4F60;&#x6CA1;&#x6709;&#x901A;&#x8FC7;<code>rp</code>&#x53C2;&#x6570;&#x8BBE;&#x7F6E;retention policy&#x7684;&#x8BDD;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x6570;&#x636E;&#x4F1A;&#x5199;&#x5230;<code>db</code>&#x9ED8;&#x8BA4;&#x7684;retention policy&#x4E2D;&#x3002;&#x60F3;&#x8981;&#x83B7;&#x53D6;&#x66F4;&#x591A;&#x53C2;&#x6570;&#x7684;&#x5B8C;&#x6574;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x79FB;&#x6B65;&#x5230;<code>API&#x53C2;&#x8003;</code>&#x7AE0;&#x8282;&#x3002;</p>
<p>POST&#x7684;&#x8BF7;&#x6C42;&#x4F53;&#x6211;&#x4EEC;&#x79F0;&#x4E4B;&#x4E3A;<code>Line Protocol</code>&#xFF0C;&#x5305;&#x542B;&#x4E86;&#x4F60;&#x5E0C;&#x671B;&#x5B58;&#x50A8;&#x7684;&#x65F6;&#x95F4;&#x5E8F;&#x5217;&#x6570;&#x636E;&#x3002;&#x5B83;&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;&#x6709;measurement&#xFF0C;tags&#xFF0C;fields&#x548C;timestamp&#x3002;measurement&#x662F;InfluxDB&#x5FC5;&#x987B;&#x7684;&#xFF0C;&#x4E25;&#x683C;&#x5730;&#x8BF4;&#xFF0C;tags&#x662F;&#x53EF;&#x9009;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x5BF9;&#x4E8E;&#x5927;&#x90E8;&#x5206;&#x6570;&#x636E;&#x90FD;&#x4F1A;&#x5305;&#x542B;tags&#x7528;&#x6765;&#x533A;&#x5206;&#x6570;&#x636E;&#x7684;&#x6765;&#x6E90;&#xFF0C;&#x8BA9;&#x67E5;&#x8BE2;&#x53D8;&#x5F97;&#x5BB9;&#x6613;&#x548C;&#x9AD8;&#x6548;&#x3002;tag&#x7684;key&#x548C;value&#x90FD;&#x5FC5;&#x987B;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#x3002;fields&#x7684;key&#x4E5F;&#x662F;&#x5FC5;&#x987B;&#x7684;&#xFF0C;&#x800C;&#x4E14;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;field&#x7684;value&#x662F;float&#x7C7B;&#x578B;&#x7684;&#x3002;timestamp&#x5728;&#x8FD9;&#x4E2A;&#x8BF7;&#x6C42;&#x884C;&#x7684;&#x6700;&#x540E;&#xFF0C;&#x662F;&#x4E00;&#x4E2A;&#x4ECE;1/1/1970 UTC&#x5F00;&#x59CB;&#x5230;&#x73B0;&#x5728;&#x7684;&#x4E00;&#x4E2A;&#x7EB3;&#x79D2;&#x7EA7;&#x7684;Unix time&#xFF0C;&#x5B83;&#x662F;&#x53EF;&#x9009;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x4F20;&#xFF0C;InfluxDB&#x4F1A;&#x4F7F;&#x7528;&#x670D;&#x52A1;&#x5668;&#x7684;&#x672C;&#x5730;&#x7684;&#x7EB3;&#x7C73;&#x7EA7;&#x7684;timestamp&#x6765;&#x4F5C;&#x4E3A;&#x6570;&#x636E;&#x7684;&#x65F6;&#x95F4;&#x6233;&#xFF0C;&#x6CE8;&#x610F;&#x65E0;&#x8BBA;&#x54EA;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x5728;InfluxDB&#x4E2D;&#x7684;timestamp&#x53EA;&#x80FD;&#x662F;UTC&#x65F6;&#x95F4;&#x3002;</p>
<h3 id="&#x540C;&#x65F6;&#x5199;&#x5165;&#x591A;&#x4E2A;&#x70B9;">&#x540C;&#x65F6;&#x5199;&#x5165;&#x591A;&#x4E2A;&#x70B9;</h3>
<p>&#x8981;&#x60F3;&#x540C;&#x65F6;&#x53D1;&#x9001;&#x591A;&#x4E2A;&#x6570;&#x636E;&#x70B9;&#x5230;&#x591A;&#x4E2A;series(&#x5728;InfluxDB&#x4E2D;measurement&#x52A0;tags&#x7EC4;&#x6210;&#x4E86;&#x4E00;&#x4E2A;series)&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x65B0;&#x7684;&#x884C;&#x6765;&#x5206;&#x5F00;&#x8FD9;&#x4E9B;&#x6570;&#x636E;&#x70B9;&#x3002;&#x8FD9;&#x79CD;&#x6279;&#x91CF;&#x53D1;&#x9001;&#x7684;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x83B7;&#x5F97;&#x66F4;&#x9AD8;&#x7684;&#x6027;&#x80FD;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x5C31;&#x662F;&#x5199;&#x4E86;&#x4E09;&#x4E2A;&#x6570;&#x636E;&#x70B9;&#x5230;<code>mydb</code>&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x3002;&#x7B2C;&#x4E00;&#x4E2A;&#x70B9;&#x6240;&#x5C5E;series&#x7684;measurement&#x4E3A;<code>cpu_load_short</code>&#xFF0C;tag&#x662F;<code>host=server02</code>&#xFF0C;timestamp&#x662F;server&#x672C;&#x5730;&#x7684;&#x65F6;&#x95F4;&#x6233;&#xFF1B;&#x7B2C;&#x4E8C;&#x4E2A;&#x70B9;&#x540C;&#x6837;&#x662F;measurement&#x4E3A;<code>cpu_load_short</code>&#xFF0C;&#x4F46;&#x662F;tag&#x4E3A;<code>host=server02,region=us-west</code>,&#x4E14;&#x6709;&#x660E;&#x786E;timestamp&#x4E3A;<code>1422568543702900257</code>&#x7684;series&#xFF1B;&#x7B2C;&#x4E09;&#x4E2A;&#x6570;&#x636E;&#x70B9;&#x548C;&#x7B2C;&#x4E8C;&#x4E2A;&#x7684;timestamp&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x4F46;&#x662F;series&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x5176;measurement&#x4E3A;<code>cpu_load_short</code>&#xFF0C;tag&#x4E3A;<code>direction=in,host=server01,region=us-west</code>&#x3002;</p>
<pre><code>curl -i -XPOST &apos;http://localhost:8086/write?db=mydb&apos; --data-binary &apos;cpu_load_short,host=server02 value=0.67
cpu_load_short,host=server02,region=us-west value=0.55 1422568543702900257
cpu_load_short,direction=in,host=server01,region=us-west value=2.0 1422568543702900257&apos;
</code></pre><h3 id="&#x5199;&#x5165;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x6570;&#x636E;">&#x5199;&#x5165;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x6570;&#x636E;</h3>
<p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>curl</code>&#x7684;<code>@filename</code>&#x6765;&#x5199;&#x5165;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4E14;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x91CC;&#x7684;&#x6570;&#x636E;&#x7684;&#x683C;&#x5F0F;&#x9700;&#x8981;&#x6EE1;&#x8DB3;InfluxDB&#x90A3;&#x79CD;&#x884C;&#x7684;&#x8BED;&#x6CD5;&#x3002;</p>
<p>&#x7ED9;&#x4E00;&#x4E2A;&#x6B63;&#x786E;&#x7684;&#x6587;&#x4EF6;(cpu_data.txt)&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>cpu_load_short,host=server02 value=0.67
cpu_load_short,host=server02,region=us-west value=0.55 1422568543702900257
cpu_load_short,direction=in,host=server01,region=us-west value=2.0 1422568543702900257
</code></pre><p>&#x770B;&#x6211;&#x4EEC;&#x5982;&#x4F55;&#x628A;<code>cpu_data.txt</code>&#x91CC;&#x7684;&#x6570;&#x636E;&#x5199;&#x5165;<code>mydb</code>&#x6570;&#x636E;&#x5E93;&#xFF1A;</p>
<pre><code>curl -i -XPOST &apos;http://localhost:8086/write?db=mydb&apos; --data-binary @cpu_data.txt
</code></pre><blockquote>
<p>&#x8BF4;&#x660E;&#xFF1A;&#x5982;&#x679C;&#x4F60;&#x7684;&#x6570;&#x636E;&#x6587;&#x4EF6;&#x7684;&#x6570;&#x636E;&#x70B9;&#x5927;&#x4E8E;5000&#x65F6;&#xFF0C;&#x4F60;&#x5FC5;&#x987B;&#x628A;&#x4ED6;&#x4EEC;&#x62C6;&#x5206;&#x5230;&#x591A;&#x4E2A;&#x6587;&#x4EF6;&#x518D;&#x5199;&#x5165;InfluxDB&#x3002;&#x56E0;&#x4E3A;&#x9ED8;&#x8BA4;&#x7684;HTTP&#x7684;timeout&#x7684;&#x503C;&#x4E3A;5&#x79D2;&#xFF0C;&#x867D;&#x7136;5&#x79D2;&#x4E4B;&#x540E;&#xFF0C;InfluxDB&#x4ECD;&#x7136;&#x4F1A;&#x8BD5;&#x56FE;&#x628A;&#x8FD9;&#x6279;&#x6570;&#x636E;&#x5199;&#x8FDB;&#x53BB;&#xFF0C;&#x4F46;&#x662F;&#x4F1A;&#x6709;&#x6570;&#x636E;&#x4E22;&#x5931;&#x7684;&#x98CE;&#x9669;&#x3002;</p>
</blockquote>
<h3 id="&#x65E0;&#x6A21;&#x5F0F;&#x8BBE;&#x8BA1;">&#x65E0;&#x6A21;&#x5F0F;&#x8BBE;&#x8BA1;</h3>
<p>InfluxDB&#x662F;&#x4E00;&#x4E2A;&#x65E0;&#x6A21;&#x5F0F;(schemaless)&#x7684;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x4EFB;&#x610F;&#x65F6;&#x95F4;&#x6DFB;&#x52A0;measurement&#xFF0C;tags&#x548C;fields&#x3002;&#x6CE8;&#x610F;&#xFF1A;&#x5982;&#x679C;&#x4F60;&#x8BD5;&#x56FE;&#x5199;&#x5165;&#x4E00;&#x4E2A;&#x548C;&#x4E4B;&#x524D;&#x7684;&#x7C7B;&#x578B;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x6570;&#x636E;(&#x4F8B;&#x5982;&#xFF0C;filed&#x5B57;&#x6BB5;&#x4E4B;&#x524D;&#x63A5;&#x6536;&#x7684;&#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;&#xFF0C;&#x73B0;&#x5728;&#x5199;&#x4E86;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x8FDB;&#x53BB;)&#xFF0C;&#x90A3;&#x4E48;InfluxDB&#x4F1A;&#x62D2;&#x7EDD;&#x8FD9;&#x4E2A;&#x6570;&#x636E;&#x3002;</p>
<h3 id="&#x5BF9;&#x4E8E;rest&#x7684;&#x4E00;&#x4E2A;&#x8BF4;&#x660E;">&#x5BF9;&#x4E8E;REST&#x7684;&#x4E00;&#x4E2A;&#x8BF4;&#x660E;</h3>
<p>InfluxDB&#x4F7F;&#x7528;HTTP&#x4F5C;&#x4E3A;&#x65B9;&#x4FBF;&#x548C;&#x5E7F;&#x6CDB;&#x652F;&#x6301;&#x7684;&#x6570;&#x636E;&#x4F20;&#x8F93;&#x534F;&#x8BAE;&#x3002;</p>
<p>&#x73B0;&#x4EE3;web&#x7684;APIs&#x90FD;&#x57FA;&#x4E8E;REST&#x7684;&#x8BBE;&#x8BA1;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x6837;&#x89E3;&#x51B3;&#x4E86;&#x4E00;&#x4E2A;&#x5171;&#x540C;&#x7684;&#x9700;&#x6C42;&#x3002;&#x56E0;&#x4E3A;&#x968F;&#x7740;&#x7EC8;&#x7AEF;&#x6570;&#x91CF;&#x7684;&#x589E;&#x957F;&#xFF0C;&#x7EC4;&#x7EC7;&#x7CFB;&#x7EDF;&#x7684;&#x9700;&#x6C42;&#x53D8;&#x5F97;&#x8D8A;&#x6765;&#x8D8A;&#x8FEB;&#x5207;&#x3002;REST&#x662F;&#x4E3A;&#x4E86;&#x7EC4;&#x7EC7;&#x5927;&#x91CF;&#x7EC8;&#x7AEF;&#x7684;&#x4E00;&#x4E2A;&#x4E1A;&#x5185;&#x8BA4;&#x53EF;&#x7684;&#x6807;&#x51C6;&#x3002;&#x8FD9;&#x79CD;&#x4E00;&#x81F4;&#x6027;&#x5BF9;&#x4E8E;&#x5F00;&#x53D1;&#x8005;&#x548C;API&#x7684;&#x6D88;&#x8D39;&#x8005;&#x90FD;&#x662F;&#x4E00;&#x4EF6;&#x597D;&#x4E8B;&#xFF1A;&#x6240;&#x6709;&#x7684;&#x53C2;&#x4E0E;&#x8005;&#x90FD;&#x77E5;&#x9053;&#x671F;&#x671B;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#x3002;</p>
<p>REST&#x7684;&#x786E;&#x662F;&#x5F88;&#x65B9;&#x4FBF;&#x7684;&#xFF0C;&#x800C;InfluxDB&#x4E5F;&#x53EA;&#x63D0;&#x4F9B;&#x4E86;&#x4E09;&#x4E2A;API&#xFF0C;&#x8FD9;&#x4F7F;&#x5F97;InfluxQL&#x5728;&#x7FFB;&#x8BD1;&#x4E3A;HTTP&#x8BF7;&#x6C42;&#x7684;&#x65F6;&#x5019;&#x5F88;&#x7B80;&#x5355;&#x4FBF;&#x6377;&#x3002; &#x6240;&#x4EE5;InfluxDB API&#x5E76;&#x4E0D;&#x662F;RESTful&#x7684;&#x3002;</p>
<h3 id="http&#x8FD4;&#x56DE;&#x503C;&#x6982;&#x8981;">HTTP&#x8FD4;&#x56DE;&#x503C;&#x6982;&#x8981;</h3>
<ul>
<li>2xx&#xFF1A;&#x5982;&#x679C;&#x4F60;&#x5199;&#x4E86;&#x6570;&#x636E;&#x540E;&#x6536;&#x5230;<code>HTTP 204 No Content</code>&#xFF0C;&#x8BF4;&#x660E;&#x5199;&#x5165;&#x6210;&#x529F;&#x4E86;&#xFF01;</li>
<li>4xx&#xFF1A;&#x8868;&#x793A;InfluxDB&#x4E0D;&#x77E5;&#x9053;&#x4F60;&#x53D1;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#x9B3C;&#x3002;</li>
<li>5xx&#xFF1A;&#x7CFB;&#x7EDF;&#x8FC7;&#x8F7D;&#x6216;&#x662F;&#x5E94;&#x7528;&#x53D7;&#x635F;&#x3002;</li>
</ul>
<p>&#x4E3E;&#x51E0;&#x4E2A;&#x8FD4;&#x56DE;&#x9519;&#x8BEF;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<ul>
<li>&#x4E4B;&#x524D;&#x63A5;&#x6536;&#x7684;&#x662F;&#x5E03;&#x5C14;&#x503C;&#xFF0C;&#x73B0;&#x5728;&#x4F60;&#x5199;&#x5165;&#x4E00;&#x4E2A;&#x6D6E;&#x70B9;&#x503C;&#xFF1A;</li>
</ul>
<pre><code>curl -i -XPOST &apos;http://localhost:8086/write?db=hamlet&apos; --data-binary &apos;tobeornottobe booleanonly=true&apos;  

curl -i -XPOST &apos;http://localhost:8086/write?db=hamlet&apos; --data-binary &apos;tobeornottobe booleanonly=5&apos;
</code></pre><p>&#x8FD9;&#x65F6;&#x7CFB;&#x7EDF;&#x8FD4;&#x56DE;&#xFF1A;</p>
<pre><code>HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: [...]
X-Influxdb-Version: 1.2.x
Date: Wed, 01 Mar 2017 19:38:01 GMT
Content-Length: 150

{&quot;error&quot;:&quot;field type conflict: input field \&quot;booleanonly\&quot; on measurement \&quot;tobeornottobe\&quot; is type float, already exists as type boolean dropped=1&quot;}
</code></pre><ul>
<li>&#x5199;&#x5165;&#x6570;&#x636E;&#x5230;&#x4E00;&#x4E2A;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#xFF1A;</li>
</ul>
<pre><code>curl -i -XPOST &apos;http://localhost:8086/write?db=atlantis&apos; --data-binary &apos;liters value=10&apos;
</code></pre><p>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;</p>
<pre><code>HTTP/1.1 404 Not Found
Content-Type: application/json
Request-Id: [...]
X-Influxdb-Version: 1.2.x
Date: Wed, 01 Mar 2017 19:38:35 GMT
Content-Length: 45

{&quot;error&quot;:&quot;database not found: \&quot;atlantis\&quot;&quot;}
</code></pre><h3 id="&#x4E0B;&#x4E00;&#x6B65;">&#x4E0B;&#x4E00;&#x6B65;</h3>
<p>&#x73B0;&#x5728;&#x4F60;&#x5DF2;&#x7ECF;&#x77E5;&#x9053;&#x4E86;&#x5982;&#x4F55;&#x901A;&#x8FC7;&#x5185;&#x7F6E;HTTP API&#x5199;&#x5165;&#x6570;&#x636E;&#x4E86;&#xFF0C;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x770B;&#x600E;&#x4E48;&#x901A;&#x8FC7;<a href="querying_data.html">&#x8BFB;&#x6570;&#x636E;</a>&#x6307;&#x5357;&#x6765;&#x8BFB;&#x51FA;&#x5B83;&#x4EEC;&#x3002;&#x60F3;&#x8981;&#x4E86;&#x89E3;&#x66F4;&#x591A;&#x5173;&#x4E8E;&#x5982;&#x4F55;&#x4F7F;&#x7528;HTTP API&#x5199;&#x6570;&#x636E;&#xFF0C;&#x8BF7;&#x53C2;&#x8003;<a href="">API&#x53C2;&#x8003;&#x6587;&#x6863;</a>&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 使用指南">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="querying_data.html" class="navigation navigation-next " aria-label="Next page: 查询数据">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"写入数据","level":"1.3.1","depth":2,"next":{"title":"查询数据","level":"1.3.2","depth":2,"path":"Guide/querying_data.md","ref":"Guide/querying_data.md","articles":[]},"previous":{"title":"使用指南","level":"1.3","depth":1,"path":"Guide/index.md","ref":"Guide/index.md","articles":[{"title":"写入数据","level":"1.3.1","depth":2,"path":"Guide/writing_data.md","ref":"Guide/writing_data.md","articles":[]},{"title":"查询数据","level":"1.3.2","depth":2,"path":"Guide/querying_data.md","ref":"Guide/querying_data.md","articles":[]},{"title":"采样和数据保留","level":"1.3.3","depth":2,"path":"Guide/downsampling_and_retention.md","ref":"Guide/downsampling_and_retention.md","articles":[]},{"title":"硬件指南","level":"1.3.4","depth":2,"path":"Guide/hardware_sizing.md","ref":"Guide/hardware_sizing.md","articles":[]},{"title":"HTTPS设置","level":"1.3.5","depth":2,"path":"Guide/https_setup.md","ref":"Guide/https_setup.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["comment"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"comment":{"highlightCommented":true},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"github":"jasper-zhang/influxdb-document-cn","theme":"default","author":"jasper","pdf":{"pageNumbers":true,"fontSize":16,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"InfluxDB中文文档","language":"en","links":{"sidebar":{"InfluxDB中文文档":"https://legacy.gitbook.com/book/jasper-zhang1/influxdb"},"gitbook":true},"gitbook":"*","description":""},"file":{"path":"Guide/writing_data.md","mtime":"2019-09-29T09:05:38.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-29T09:10:37.143Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-comment/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

